home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / w3 / w3-emulate.el.z / w3-emulate.el
Encoding:
Text File  |  1998-05-21  |  10.9 KB  |  271 lines

  1. ;;; w3-emulate.el --- All variable definitions for emacs-w3
  2. ;; Author: wmperry
  3. ;; Created: 1997/10/17 14:08:13
  4. ;; Version: 1.15
  5. ;; Keywords: comm, help, hypermedia
  6.  
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. ;;; Copyright (c) 1996 by William M. Perry <wmperry@cs.indiana.edu>
  9. ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
  10. ;;;
  11. ;;; This file is part of GNU Emacs.
  12. ;;;
  13. ;;; GNU Emacs is free software; you can redistribute it and/or modify
  14. ;;; it under the terms of the GNU General Public License as published by
  15. ;;; the Free Software Foundation; either version 2, or (at your option)
  16. ;;; any later version.
  17. ;;;
  18. ;;; GNU Emacs is distributed in the hope that it will be useful,
  19. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;;; GNU General Public License for more details.
  22. ;;;
  23. ;;; You should have received a copy of the GNU General Public License
  24. ;;; along with GNU Emacs; see the file COPYING.  If not, write to the
  25. ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  26. ;;; Boston, MA 02111-1307, USA.
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28.  
  29. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  30. ;;; Provide emulations of various other web browsers
  31. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  32. (require 'w3-vars)
  33.  
  34.  
  35. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  36. ;; First, we emulate Netscape 2.x
  37. ;; ------------------------------
  38. ;; This entails mainly a few new keybindings.
  39. ;; Alt-S    == Save As
  40. ;; Alt-M    == New Mail Message
  41. ;; Alt-N    == New Window
  42. ;; Alt-L    == Open Location
  43. ;; Alt-O    == Open File
  44. ;; Alt-P    == Print
  45. ;; Alt-Q    == Quit
  46. ;; Alt-F    == Search
  47. ;; Alt-G    == Search Again
  48. ;; Alt-R    == Reload
  49. ;; Alt-I    == Load Images
  50. ;; Alt-A    == Add Bookmark
  51. ;; Alt-B    == Show Bookmark Window
  52. ;; Alt-H    == Show History Window
  53. ;; Alt-Left == Back
  54. ;; Alt-Right== Forward
  55. ;; Right    == Scroll left
  56. ;; Left     == Scroll right
  57. ;; Up       == Smooth scroll up
  58. ;; Down     == Smooth scroll down
  59. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  60.  
  61. (define-key w3-netscape-emulation-minor-mode-map "\M-s" 'w3-save-as)
  62. (define-key w3-netscape-emulation-minor-mode-map "\M-m" 'w3-mailto)
  63. (define-key w3-netscape-emulation-minor-mode-map "\M-n" 'make-frame)
  64. (define-key w3-netscape-emulation-minor-mode-map "\M-l" 'w3-fetch)
  65. (define-key w3-netscape-emulation-minor-mode-map "\M-o" 'w3-open-local)
  66. (define-key w3-netscape-emulation-minor-mode-map "\M-p" 'w3-print-this-url)
  67. (define-key w3-netscape-emulation-minor-mode-map "\M-q" 'w3-quit)
  68. (define-key w3-netscape-emulation-minor-mode-map "\M-f" 'w3-search-forward)
  69. (define-key w3-netscape-emulation-minor-mode-map "\M-g" 'w3-search-again)
  70. (define-key w3-netscape-emulation-minor-mode-map "\M-r" 'w3-reload-document)
  71. (define-key w3-netscape-emulation-minor-mode-map "\M-i" 'w3-load-delayed-images)
  72. (define-key w3-netscape-emulation-minor-mode-map "\M-a" 'w3-hotlist-add-document)
  73. (define-key w3-netscape-emulation-minor-mode-map "\M-b" 'w3-show-hotlist)
  74. (define-key w3-netscape-emulation-minor-mode-map "\M-h" 'w3-show-history-list)
  75.  
  76. (define-key w3-netscape-emulation-minor-mode-map [up]
  77.   (function (lambda () (interactive) (scroll-down 1))))
  78. (define-key w3-netscape-emulation-minor-mode-map [down]
  79.   (function (lambda () (interactive) (scroll-up 1))))
  80. (define-key w3-netscape-emulation-minor-mode-map [right] 'scroll-left)
  81. (define-key w3-netscape-emulation-minor-mode-map [left] 'scroll-right)
  82. (define-key w3-netscape-emulation-minor-mode-map [(meta left)]
  83.   'w3-history-backward)
  84. (define-key w3-netscape-emulation-minor-mode-map [(meta right)]
  85.   'w3-history-forward)
  86.  
  87. (defun turn-on-netscape-emulation ()
  88.   (interactive)
  89.   (w3-lynx-emulation-minor-mode 0)
  90.   (w3-netscape-emulation-minor-mode 1))
  91.  
  92. (defun w3-netscape-emulation-minor-mode (&optional arg)
  93.   "Minor mode for emulating netscape key navigation."
  94.   (interactive "P")
  95.   (cond
  96.    ((null arg)
  97.     (setq w3-netscape-emulation-minor-mode
  98.       (not w3-netscape-emulation-minor-mode))
  99.     (if w3-netscape-emulation-minor-mode
  100.     (setq w3-lynx-emulation-minor-mode nil)))
  101.    ((= 0 arg)
  102.     (setq w3-netscape-emulation-minor-mode nil))
  103.    (t
  104.     (setq w3-lynx-emulation-minor-mode nil
  105.       w3-netscape-emulation-minor-mode t)))
  106.   )
  107.  
  108. (defsubst w3-skip-word ()
  109.   (skip-chars-forward "^ \t\n\r")
  110.   (skip-chars-forward " \t"))
  111.  
  112.  
  113. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  114. ;; Now, lets try Lynx
  115. ;; ------------------
  116. ;; A few keybindings and modifications to some default functions
  117. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  118.  
  119. (defun turn-on-lynx-emulation ()
  120.   (interactive)
  121.   (w3-netscape-emulation-minor-mode 0)
  122.   (w3-lynx-emulation-minor-mode 1))
  123.  
  124. (defun w3-lynx-emulation-minor-mode (&optional arg)
  125.   "Minor mode for emulating lynx key navigation."
  126.   (interactive "P")
  127.   (cond
  128.    ((null arg)
  129.     (setq w3-lynx-emulation-minor-mode
  130.       (not w3-lynx-emulation-minor-mode))
  131.     (if w3-lynx-emulation-minor-mode
  132.     (setq w3-netscape-emulation-minor-mode nil)))
  133.    ((= 0 arg)
  134.     (setq w3-lynx-emulation-minor-mode nil))
  135.    (t
  136.     (setq w3-lynx-emulation-minor-mode t
  137.       w3-netscape-emulation-minor-mode nil))))
  138.  
  139. ;; The list of keybindings for lynx minor mode was compiled from:
  140. ;; http://www.crl.com/~subir/lynx/lynx_help/keystroke_commands/keystroke_help.htm
  141.  
  142. ;; Movement
  143. (define-key w3-lynx-emulation-minor-mode-map [up]   'widget-backward)
  144. (define-key w3-lynx-emulation-minor-mode-map [down] 'widget-forward)
  145. (define-key w3-lynx-emulation-minor-mode-map [right] 'widget-button-press)
  146. (define-key w3-lynx-emulation-minor-mode-map [left] 'w3-history-backward)
  147.  
  148. ;; Scrolling
  149. (define-key w3-lynx-emulation-minor-mode-map "+"    'w3-scroll-up)
  150. (define-key w3-lynx-emulation-minor-mode-map "-"    'scroll-down)
  151. (define-key w3-lynx-emulation-minor-mode-map "b"    'scroll-down)
  152. (define-key w3-lynx-emulation-minor-mode-map "\C-a" 'w3-start-of-document)
  153. (define-key w3-lynx-emulation-minor-mode-map "\C-e" 'w3-end-of-document)
  154. (define-key w3-lynx-emulation-minor-mode-map "\C-f" 'scroll-down)
  155. (define-key w3-lynx-emulation-minor-mode-map "\C-n" 'ignore) ; down 2
  156. (define-key w3-lynx-emulation-minor-mode-map "\C-p" 'ignore) ; up 2
  157. (define-key w3-lynx-emulation-minor-mode-map ")"    'ignore) ; forward half
  158. (define-key w3-lynx-emulation-minor-mode-map "("    'ignore) ; back half
  159. (define-key w3-lynx-emulation-minor-mode-map "#"    'w3-toggle-toolbar)
  160.  
  161. ;; Dired bindings don't have any meaning for us
  162.  
  163. ;; Other
  164. (define-key w3-lynx-emulation-minor-mode-map "?"   'w3-help)
  165. (define-key w3-lynx-emulation-minor-mode-map "a"   'w3-hotlist-add-document)
  166. (define-key w3-lynx-emulation-minor-mode-map "c"   'w3-mail-document-author)
  167. (define-key w3-lynx-emulation-minor-mode-map "d"   'w3-download-url) 
  168. (define-key w3-lynx-emulation-minor-mode-map "e"   'ignore) ; edit current
  169. (define-key w3-lynx-emulation-minor-mode-map "f"   'dired)
  170. (define-key w3-lynx-emulation-minor-mode-map "g"   'w3-fetch)
  171. (define-key w3-lynx-emulation-minor-mode-map "h"   'w3-help)
  172. (define-key w3-lynx-emulation-minor-mode-map "i"   'ignore)
  173. (define-key w3-lynx-emulation-minor-mode-map "j"   'w3-use-hotlist)
  174. (define-key w3-lynx-emulation-minor-mode-map "k"   'describe-mode)
  175. (define-key w3-lynx-emulation-minor-mode-map "l"   'w3-complete-link)
  176. (define-key w3-lynx-emulation-minor-mode-map "m"   'w3)
  177. (define-key w3-lynx-emulation-minor-mode-map "n"   'w3-search-again)
  178. (define-key w3-lynx-emulation-minor-mode-map "o"   'w3-preferences-edit)
  179. (define-key w3-lynx-emulation-minor-mode-map "p"   'w3-print-this-url)
  180. (define-key w3-lynx-emulation-minor-mode-map "q"   'w3-quit)
  181. (define-key w3-lynx-emulation-minor-mode-map "r"   'w3-hotlist-delete)
  182. (define-key w3-lynx-emulation-minor-mode-map "t"   'ignore) ; tag
  183. (define-key w3-lynx-emulation-minor-mode-map "u"   'w3-history-backward)
  184. (define-key w3-lynx-emulation-minor-mode-map "/"   'w3-search-forward)
  185. (define-key w3-lynx-emulation-minor-mode-map "v"   'w3-show-hotlist)
  186. (define-key w3-lynx-emulation-minor-mode-map "V"   'w3-show-hotlist)
  187. (define-key w3-lynx-emulation-minor-mode-map "x"   'widget-button-press)
  188. (define-key w3-lynx-emulation-minor-mode-map "z"   'keyboard-quit)
  189. (define-key w3-lynx-emulation-minor-mode-map "="   'w3-document-information)
  190. (define-key w3-lynx-emulation-minor-mode-map "\\"  'w3-source-document)
  191. (define-key w3-lynx-emulation-minor-mode-map "!"   'shell)
  192. (define-key w3-lynx-emulation-minor-mode-map "'"   'ignore) ; toggle comment
  193. (define-key w3-lynx-emulation-minor-mode-map "`"   'ignore) ; toggle comment
  194. (define-key w3-lynx-emulation-minor-mode-map "*"   'ignore) ; toggle image_links
  195. (define-key w3-lynx-emulation-minor-mode-map "@"   'ignore) ; toggle raw 8-bit
  196. (define-key w3-lynx-emulation-minor-mode-map "["   'ignore) ; pseudo-inlines
  197. (define-key w3-lynx-emulation-minor-mode-map "]"   'ignore) ; send head
  198. (define-key w3-lynx-emulation-minor-mode-map "\""  'ignore) ; toggle quoting
  199. (define-key w3-lynx-emulation-minor-mode-map "\C-r" 'w3-reload-document)
  200. (define-key w3-lynx-emulation-minor-mode-map "\C-w" 'w3-refresh-buffer)
  201. (define-key w3-lynx-emulation-minor-mode-map "\C-u" 'ignore) ; erase input
  202. (define-key w3-lynx-emulation-minor-mode-map "\C-g" 'keyboard-quit)
  203. (define-key w3-lynx-emulation-minor-mode-map "\C-t" 'ignore) ; toggle trace
  204. (define-key w3-lynx-emulation-minor-mode-map "\C-k" 'ignore) ; cookie jar
  205.  
  206. ;; Things to masquerade as other browsers in the user-agent field
  207. ;; of an HTTP request.
  208. (defun w3-masquerade-stub (arg app version)
  209.   (if (null arg)
  210.       (setq arg (if (equal url-package-name "Emacs-W3") 1 0)))
  211.   (if (= 0 arg)
  212.       (setq url-package-name "Emacs-W3"
  213.         url-package-version w3-version-number)
  214.     (setq url-package-name app
  215.       url-package-version version)))
  216.  
  217. (defun w3-lynx-masquerade-mode (&optional arg)
  218.   (interactive "P")
  219.   (w3-masquerade-stub arg "Lynx" "2.6"))
  220.  
  221. (defun turn-on-lynx-masquerade-mode ()
  222.   (interactive)
  223.   (w3-lynx-masquerade-mode 1))
  224.  
  225. (defun turn-off-lynx-masquerade-mode ()
  226.   (interactive)
  227.   (w3-lynx-masquerade-mode 0))
  228.  
  229. (defun w3-netscape-masquerade-mode (&optional arg)
  230.   (interactive "P")
  231.   (w3-masquerade-stub arg "Mozilla" "4.0"))
  232.  
  233. (defun turn-on-netscape-masquerade-mode ()
  234.   (interactive)
  235.   (w3-netscape-masquerade-mode 1))
  236.  
  237. (defun turn-off-netscape-masquerade-mode ()
  238.   (interactive)
  239.   (w3-netscape-masquerade-mode 0))
  240.  
  241. (defun w3-ie-masquerade-mode (&optional arg)
  242.   (interactive "P")
  243.   (w3-masquerade-stub arg "Internet_Explorer" "3.02"))
  244.  
  245. (defun turn-on-ie-masquerade-mode ()
  246.   (interactive)
  247.   (w3-ie-masquerade-mode 1))
  248.  
  249. (defun turn-off-ie-masquerade-mode ()
  250.   (interactive)
  251.   (w3-ie-masquerade-mode 0))
  252.  
  253. (defun w3-arena-masquerade-mode (&optional arg)
  254.   (interactive "P")
  255.   (w3-masquerade-stub arg "Arena" "0.9"))
  256.  
  257. (defun turn-on-arena-masquerade-mode ()
  258.   (interactive)
  259.   (w3-arena-masquerade-mode 1))
  260.  
  261. (defun turn-off-arena-masquerade-mode ()
  262.   (interactive)
  263.   (w3-arena-masquerade-mode 0))
  264.  
  265. ;;
  266. (provide 'w3-emulate)
  267.  
  268. ;;; Local Variables:
  269. ;;; truncate-lines: t
  270. ;;; End:
  271.